package com.ctsi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctsi.common.util.Search;
import com.ctsi.core.common.util.StringUtil;
import com.ctsi.system.entity.Notice;
import com.ctsi.system.mapper.NoticeMapper;
import com.ctsi.system.service.INoticeService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 通知表 服务实现类
 * </p>
 *
 * @author wang xiao xiang
 */
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {

		@Override
		public IPage<Notice> listPage(Page page, Search search) {
			LambdaQueryWrapper<Notice> queryWrapper = new LambdaQueryWrapper<>();
			if (StringUtil.isNotBlank(search.getStartDate())) {
				queryWrapper.between(Notice::getCreateTime, search.getStartDate(), search.getEndDate());
			}
			if (StringUtil.isNotBlank(search.getKeyword())) {
				queryWrapper.like(Notice::getId, search.getKeyword());
			}
			queryWrapper.orderByDesc(Notice::getCreateTime);
			return this.baseMapper.selectPage(page, queryWrapper);
		}
}
